{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e42f1695-d27b-4e6b-95f1-1bf823972573",
   "metadata": {},
   "source": [
    "# Interactive Panel App with `rx`\n",
    "\n",
    "A dynamic sine curve that updates based on user-controlled amplitude and frequency. This example uses `pn.rx()` to link [Panel](https://panel.holoviz.org) widgets with a plotting function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dea49469-0a57-4eb3-b6b7-b207421ca2d6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import hvplot.pandas  # noqa\n",
    "import panel as pn\n",
    "\n",
    "x = np.linspace(0, 4 * np.pi, 200)\n",
    "df = pd.DataFrame({'x': x})\n",
    "\n",
    "amp_slider = pn.widgets.FloatSlider(\n",
    "    name='Amplitude', start=-5.0, end=5.0,\n",
    "    step=0.1, value=1.0, width=200,\n",
    ")\n",
    "freq_slider = pn.widgets.FloatSlider(\n",
    "    name='Frequency', start=0.1, end=5.1,\n",
    "    step=0.1, value=1.0, width=200,\n",
    ")\n",
    "\n",
    "def sine_plot(amplitude, frequency):\n",
    "    df['y'] = amplitude * np.sin(frequency * df['x'])\n",
    "    return df.hvplot.line(\n",
    "        x='x', y='y', title='Interactive Sine Wave',\n",
    "        frame_width=400,\n",
    "    )\n",
    "\n",
    "pn.rx(sine_plot)(amp_slider, freq_slider)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ffd2db9-3e2e-4fae-a687-7c07153158b1",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Line Plots reference documentation](../../ref/api/manual/hvplot.hvPlot.line.ipynb)\n",
    "- [Panel Component Gallery](https://panel.holoviz.org/reference/index.html)\n",
    "- [Panel Reactive Expression How-To Guide](https://panel.holoviz.org/how_to/interactivity/hvplot_interactive.html)\n",
    "- [Param Reactive Expressions Guide](https://param.holoviz.org/user_guide/Reactive_Expressions.html)\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
